<meta charset="utf-8" />
<div class="breadcrumbs" id="breadcrumbs">
	<ul class="breadcrumb">
		<li>
			<i class="ace-icon fa fa-home home-icon"></i>
			<a href="#">首页</a>
		</li>
	</ul><!-- /.breadcrumb -->
</div>
<div class="page-content">
	<div class="row ">
		<div class="col-sm-6">
			<div class="widget-box" style="margin-bottom: 0px;">
				<div class="widget-header widget-header-flat">
					<h4 class="widget-title lighter">
						<i class="ace-icon fa fa-signal"></i> 需购设备信息统计
					</h4>
					<div class="widget-toolbar">
						<a href="#" data-action="collapse"> <i
							class="ace-icon fa fa-chevron-up"></i>
						</a>
					</div>
				</div>

				<div class="widget-body" style="display: block; height: 305px;">
					<div class="widget-main padding-0">
						<div id="news2">
							<div id="dataPage">
								<div id="needItems" style="width: 100%;height:300px;"></div>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
		
		<div class="col-sm-6">
			<div class="widget-box" style="margin-bottom: 0px;">
				<div class="widget-header widget-header-flat">
					<h4 class="widget-title lighter">
						<i class="ace-icon fa fa-signal"></i> 库存设备信息统计
					</h4>
					<div class="widget-toolbar">
						<a href="#" data-action="collapse"> <i
							class="ace-icon fa fa-chevron-up"></i>
						</a>
					</div>
				</div>

				<div class="widget-body" style="display: block; height: 305px;">
					<div class="widget-main padding-0">
						<div id="news2">
							<div id="dataPage">
								<div id="allItems" style="width: 100%;height:300px;"></div>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
</div>
<!-- 存储统计数据信息 -->
<div id="database" hidden="hidden">
	<!-- 需购设备 -->
	<input id="buy" type="text" value="0"> <!-- 默认值为0 -->
	<input id="audit" type="text" value="0">
	<input id="pass" type="text" value="0">
	<input id="reject" type="text" value="0">
	<!-- 库存设备 -->
	<input id="repair" type="text" value="0">
	<input id="new" type="text" value="0">
	<input id="scrap" type="text" value="0">
</div>
<!-- 获取统计图所需的数据信息 -->
<script type="text/javascript">
	/**
	 * 获取统计图数据
	 */
	 
	 $.ajax({ type:"GET", url : "home/getStatistical", async : false,
		 success : function(resp){
			 $.each(resp.itemsCategory, function(i, v) {
				packlist1(v);
			 });
				 
			 $.each(resp.needItemsCategory, function(i, v) {
				packlist2(v);
			 });
		}
	}); 
	/**
	 * 库存信息
	 */
	function packlist1(v) { 
		if(v.status==1){
			$("#new").val(v.counts);
		}else if(v.status==2){
			$("#repair").val(v.counts);
		}else if(v.status==3){
			$("#scrap").val(v.counts);
		}
	}
	
	/**
	 * 需购设备信息
	 */
	function packlist2(v) { 
		if(v.status==0){
			$("#audit").val(v.counts);
		}else if(v.status==1){
			$("#pass").val(v.counts);
		}else if(v.status==-1){
			$("#reject").val(v.counts);
		}else if(v.status==-2){
			$("#buy").val(v.counts);
		}
	}
</script>
<!-- 需购设备信息统计 -->
<script type="text/javascript">
 // 基于准备好的dom，初始化echarts实例
var myChart1 = echarts.init(document.getElementById('needItems'));
 
option1 = {
    tooltip : {
        trigger: 'item',
        formatter: "{a} <br/>{b} : {c} ({d}%)"
    },
    
    series : [
        {
            name: '数量统计',
            type: 'pie',
            radius : '80%',
            center: ['50%', '50%'],
            data:[
                {value:$("#pass").val(), name:'审核通过'},
                {value:$("#reject").val(), name:'审核驳回'},
                {value:$("#audit").val(), name:'待审核'},
                {value:$("#buy").val(), name:'已购买'}
            ],
            itemStyle: {
                emphasis: {
                    shadowBlur: 10,
                    shadowOffsetX: 0,
                    shadowColor: 'rgba(0, 0, 0, 0.5)'
                }
            }
        }
    ]
};
// 使用刚指定的配置项和数据显示图表。
myChart1.setOption(option1);
</script>
<!-- 库存设备信息统计 -->
<script type="text/javascript">
 // 基于准备好的dom，初始化echarts实例
var myChart3 = echarts.init(document.getElementById('allItems'));
 
option3 = {
    tooltip : {
        trigger: 'item',
        formatter: "{a} <br/>{b} : {c} ({d}%)"
    },
    
    series : [
        {
            name: '数量统计',
            type: 'pie',
            radius : '80%',
            center: ['50%', '50%'],
            data:[
                {value:$("#new").val(), name:'新添设备'},
                {value:$("#repair").val(), name:'待修设备'},
                {value:$("#scrap").val(), name:'报废设备'},
            ],
            itemStyle: {
                emphasis: {
                    shadowBlur: 10,
                    shadowOffsetX: 0,
                    shadowColor: 'rgba(0, 0, 0, 0.5)'
                }
            }
        }
    ]
};
// 使用刚指定的配置项和数据显示图表。
myChart3.setOption(option3);
</script>

